/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InternalFrame_Rekap.java
 *
 * Created on Nov 23, 2011, 9:21:16 PM
 */
package Boundaries;

import Controller.Rekap_Controller;
import Entities.Sewa;
import TableModel.Persewaan_List;
import TableModel.Persewaan_Rekap_TableModel;
import TableModel.Persewaan_TableModel;
import TableModel.Servis_List;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRTableModelDataSource;
import net.sf.jasperreports.view.JasperViewer;

/**
 *
 * @author Tea-Nose
 */
public class InternalFrame_Rekap extends javax.swing.JInternalFrame {

    Persewaan_Rekap_TableModel persewaan_Rekap_TableModel;

    /** Creates new form InternalFrame_Rekap */
    public InternalFrame_Rekap(String nama) {
        initComponents();
        TimerTask timerTask = new TimerTask() {

            public void run() {
                Date g = new Date();
                label_dateRekap.setText(g.toLocaleString());
            }
        };
        Timer t = new Timer();
        t.scheduleAtFixedRate(timerTask, 0, 1000);

        table_Rekap.setVisible(false);
        label_nilaiNamaUser.setText(nama);
        jLabel2.setText("0");
        jLabel4.setText("0");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel_Rekap = new javax.swing.JPanel();
        label_nilaiNamaUser = new javax.swing.JLabel();
        label_bulanRekap = new javax.swing.JLabel();
        label_dateRekap = new javax.swing.JLabel();
        label_namaUserLabel = new javax.swing.JLabel();
        scrollPane_dataSewa = new javax.swing.JScrollPane();
        table_Rekap = new javax.swing.JTable();
        label_JumlahKendaraan = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        label_JumlahPendapatan = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        button_cetakRekap = new javax.swing.JButton();
        yearChooser_Tahun = new com.toedter.calendar.JYearChooser();
        comboBox_Bulan = new javax.swing.JComboBox();
        button_ProccesBulan = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();

        setTitle("Rekap Data Sewa");
        setPreferredSize(new java.awt.Dimension(1010, 480));
        getContentPane().setLayout(null);

        panel_Rekap.setBackground(new java.awt.Color(204, 204, 255));

        label_nilaiNamaUser.setText("Mr. X");

        label_bulanRekap.setText("Bulan Sewa Yang Ingin Direkap");

        label_dateRekap.setText("jLabel3");

        label_namaUserLabel.setText("Nama User");

        scrollPane_dataSewa.setBackground(new java.awt.Color(204, 204, 255));
        scrollPane_dataSewa.setBorder(javax.swing.BorderFactory.createTitledBorder("Data Sewa"));

        table_Rekap.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "No. Faktur", "Nama Penyewa", "Alamat Penyewa", "No Telp Penyewa", "Tanggal Sewa", "Uang Sewa", "Tanggal Kembali", "Uang Denda", "No Polisi", "Keterlambatan"
            }
        ));
        scrollPane_dataSewa.setViewportView(table_Rekap);

        label_JumlahKendaraan.setText("Jumlah Kendaraan yang Disewa");

        label_JumlahPendapatan.setText("Jumlah Pendapatan ");

        button_cetakRekap.setText("Cetak Rekap");
        button_cetakRekap.setEnabled(false);
        button_cetakRekap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_cetakRekapActionPerformed(evt);
            }
        });

        yearChooser_Tahun.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                yearChooser_TahunPropertyChange(evt);
            }
        });

        comboBox_Bulan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "January", "February", "March", "April", "May", "June ", "July", "August", "September", "October", "November", "December" }));
        comboBox_Bulan.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboBox_BulanItemStateChanged(evt);
            }
        });

        button_ProccesBulan.setText("Procces");
        button_ProccesBulan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_ProccesBulanActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panel_RekapLayout = new javax.swing.GroupLayout(panel_Rekap);
        panel_Rekap.setLayout(panel_RekapLayout);
        panel_RekapLayout.setHorizontalGroup(
            panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_RekapLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_bulanRekap, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panel_RekapLayout.createSequentialGroup()
                        .addComponent(label_namaUserLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(113, 113, 113)
                        .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panel_RekapLayout.createSequentialGroup()
                                .addComponent(label_nilaiNamaUser, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 625, Short.MAX_VALUE)
                                .addComponent(label_dateRekap)
                                .addGap(54, 54, 54))
                            .addGroup(panel_RekapLayout.createSequentialGroup()
                                .addComponent(comboBox_Bulan, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(yearChooser_Tahun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(button_ProccesBulan)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 479, Short.MAX_VALUE)))))
                .addGap(54, 54, 54))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_RekapLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(button_cetakRekap, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 560, Short.MAX_VALUE)
                .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_RekapLayout.createSequentialGroup()
                        .addComponent(label_JumlahPendapatan, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panel_RekapLayout.createSequentialGroup()
                        .addComponent(label_JumlahKendaraan, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(panel_RekapLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scrollPane_dataSewa, javax.swing.GroupLayout.PREFERRED_SIZE, 981, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );
        panel_RekapLayout.setVerticalGroup(
            panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_RekapLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_namaUserLabel)
                    .addComponent(label_nilaiNamaUser)
                    .addComponent(label_dateRekap, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(label_bulanRekap)
                        .addComponent(comboBox_Bulan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(yearChooser_Tahun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(button_ProccesBulan))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollPane_dataSewa, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_RekapLayout.createSequentialGroup()
                        .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_JumlahPendapatan)
                            .addComponent(jLabel4))
                        .addGap(6, 6, 6)
                        .addGroup(panel_RekapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_JumlahKendaraan)
                            .addComponent(jLabel2)))
                    .addComponent(button_cetakRekap, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(75, 75, 75))
        );

        getContentPane().add(panel_Rekap);
        panel_Rekap.setBounds(0, 101, 1010, 350);

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Boundaries/RekapPersewaan Kendaraan.jpg"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 940, 103);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 70, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel1);
        jPanel1.setBounds(940, 0, 70, 100);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void button_cetakRekapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_cetakRekapActionPerformed
        // TODO add your handling code here:
        Rekap_Controller rek_Con = new Rekap_Controller(this);
    }//GEN-LAST:event_button_cetakRekapActionPerformed

    private void button_ProccesBulanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_ProccesBulanActionPerformed
        Rekap_Controller rek_Con = new Rekap_Controller();
        rek_Con.getDataSewa(this);

    }//GEN-LAST:event_button_ProccesBulanActionPerformed

    private void comboBox_BulanItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboBox_BulanItemStateChanged
        // TODO add your handling code here:
        button_cetakRekap.setEnabled(false);
    }//GEN-LAST:event_comboBox_BulanItemStateChanged

    private void yearChooser_TahunPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_yearChooser_TahunPropertyChange
        // TODO add your handling code here:
        button_cetakRekap.setEnabled(false);
    }//GEN-LAST:event_yearChooser_TahunPropertyChange

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton button_ProccesBulan;
    public javax.swing.JButton button_cetakRekap;
    public javax.swing.JComboBox comboBox_Bulan;
    private javax.swing.JLabel jLabel1;
    public javax.swing.JLabel jLabel2;
    public javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel label_JumlahKendaraan;
    private javax.swing.JLabel label_JumlahPendapatan;
    private javax.swing.JLabel label_bulanRekap;
    private javax.swing.JLabel label_dateRekap;
    private javax.swing.JLabel label_namaUserLabel;
    private javax.swing.JLabel label_nilaiNamaUser;
    private javax.swing.JPanel panel_Rekap;
    private javax.swing.JScrollPane scrollPane_dataSewa;
    public javax.swing.JTable table_Rekap;
    public com.toedter.calendar.JYearChooser yearChooser_Tahun;
    // End of variables declaration//GEN-END:variables
}
